package info.techgeek.labs.java5Features.thread.arv;

/*
import info.techgeek.dis.helper.IListenerConstant;
import info.techgeek.dis.helper.JiraEventListenerProperties;
//import info.techgeek.dis.threadpool.CRQToTaskThreadPoolExecuter;
import info.techgeek.dis.threadpool.reader.CRQToTaskThreadPoolReader;
import info.techgeek.dis.view.JiraFieldsBean;

import java.sql.Timestamp;

import org.apache.log4j.Logger;

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.event.issue.AbstractIssueEventListener;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.fields.CustomField;

/**
 * CRQToTask Listner Execute in CRQ issue Creating Child Task when user press
 * "Accept" link in workflow. CRQToTaskThreadPoolExecuter can be used to Handle
 * Asynchronous request from server
 * 
 * @author techgeek
 * 
 **/
/*
public class CRQToTaskListener extends AbstractIssueEventListener 
{
	private static final Logger LOG = Logger.getLogger(CRQToTaskListener.class);
	private JiraEventListenerProperties resourceBundle = new JiraEventListenerProperties();

	/**
	 * workFlowEvent method automatically invoke when Jira events fires.
	 */
	/*
	public void workflowEvent(IssueEvent event) 
	{
		// readProperty File to get the Value
		resourceBundle.readPropertyFile();
		final Issue issueFieldValue = event.getIssue();
		// Check whether issue belongs to CRQ
		if ("CRQ".equalsIgnoreCase(issueFieldValue.getIssueTypeObject()
				.getName())) 
		{
			LOG.warn("***********************************");
			LOG.warn("*                                 *");
			LOG.warn("* CRQTaskListener   - Workflow    *");
			LOG.warn("*                                 *");
			LOG.warn("***********************************");
			IssueManager issueManager = ComponentManager.getInstance()
					.getIssueManager();
			final CustomFieldManager fieldManager = ComponentManager
					.getInstance().getCustomFieldManager();
			final Issue issue = issueManager.getIssueObject(issueFieldValue.getKey());
			final String parentKeyValue = issueFieldValue.getKey();
			LOG.warn("CRQTaskListener This is event.getEventTypeId() : "
					+ event.getEventTypeId());
			// Check whether event type is Accept
			if (resourceBundle.childIssueEventId != null
					&& !"".equals(resourceBundle.childIssueEventId)
					&& event.getEventTypeId() == Integer
							.parseInt(resourceBundle.childIssueEventId)) 
			{
				CustomField summaryCustom = fieldManager
						.getCustomFieldObjectByName(resourceBundle.summary);
				String summaryCustomStr = issue
						.getCustomFieldValue(summaryCustom) != null ? issue
						.getCustomFieldValue(summaryCustom).toString() : "";
				CustomField descCustom = fieldManager
						.getCustomFieldObjectByName(resourceBundle.taskDescription);

				String descCustomStr = issue.getCustomFieldValue(descCustom) != null ? issue
						.getCustomFieldValue(descCustom).toString()
						: "";

				CustomField priorityCustom = fieldManager
						.getCustomFieldObjectByName(resourceBundle.priority);
				String priorityCustomStr = issue
						.getCustomFieldValue(priorityCustom) != null ? issue
						.getCustomFieldValue(priorityCustom).toString() : "";

				CustomField attivitaField = fieldManager
						.getCustomFieldObjectByName(resourceBundle.projectActivity);
				String activityFromJira = (String) issue
						.getCustomFieldValue(attivitaField);

				CustomField componentField = fieldManager
						.getCustomFieldObjectByName(resourceBundle.component);
				String componentFromJira = (String) issue
						.getCustomFieldValue(componentField);

				CustomField classificatione = fieldManager
						.getCustomFieldObjectByName(resourceBundle.classificazione);
				String classificazione = (String) issue
						.getCustomFieldValue(classificatione);

				CustomField customFieldTaskScadenza = fieldManager
						.getCustomFieldObjectByName(resourceBundle.taskScadenza);
				Timestamp taskScadenza = (Timestamp) issue
						.getCustomFieldValue(customFieldTaskScadenza);
				
				CustomField customFieldTaskInizio = fieldManager
				.getCustomFieldObjectByName(resourceBundle.taskInizio);
				Timestamp taskInizio = (Timestamp) issue
				.getCustomFieldValue(customFieldTaskInizio);
				LOG.warn("***********taskInizio**************"+taskInizio);
				JiraFieldsBean jiraFieldsBean = new JiraFieldsBean();
				jiraFieldsBean.setClassificazioneImpatto(classificazione);
				jiraFieldsBean.setSummary(summaryCustomStr);
				jiraFieldsBean.setParentIssueKey(parentKeyValue);
				jiraFieldsBean.setCrqIssueKey(parentKeyValue);
				jiraFieldsBean.setScadenza(taskScadenza);
				jiraFieldsBean.setInizio(taskInizio);
				// Remote User Setting
				jiraFieldsBean.setRemoteUser(event.getRemoteUser());
				jiraFieldsBean.setCrqIssueId(issueFieldValue.getId());

				if (IListenerConstant.HIGHEST.equals(priorityCustomStr)) {
					jiraFieldsBean.setPriority(resourceBundle.highest);
				} else if (IListenerConstant.HIGH.equals(priorityCustomStr)) {
					jiraFieldsBean.setPriority(resourceBundle.high);

				} else if (IListenerConstant.MEDIUM.equals(priorityCustomStr)) {
					jiraFieldsBean.setPriority(resourceBundle.medium);

				} else if (IListenerConstant.LOW.equals(priorityCustomStr)) {
					jiraFieldsBean.setPriority(resourceBundle.low);

				} else if (IListenerConstant.LOWEST.equals(priorityCustomStr)) {
					jiraFieldsBean.setPriority(resourceBundle.lowest);

				}
				jiraFieldsBean.setComponent(componentFromJira);

				CustomField customFieldAmb = fieldManager
						.getCustomFieldObjectByName(resourceBundle.ambienteName);
				jiraFieldsBean.setAmbiente((String) issue
						.getCustomFieldValue(customFieldAmb));
				jiraFieldsBean.setDescription(descCustomStr);
				jiraFieldsBean.setActivitiyId(activityFromJira);

				CustomField applicationField = fieldManager
						.getCustomFieldObjectByName(resourceBundle.applicazioneName);
				String applicationValue = (String) issue
						.getCustomFieldValue(applicationField);
				jiraFieldsBean.setApplicationId(applicationValue);
				// ThreadPool is used for Handle Asynchronous Request
				CRQToTaskThreadPoolReader crqTaskListenerUpdateThreadPoolReader = new CRQToTaskThreadPoolReader();
				crqTaskListenerUpdateThreadPoolReader
						.setJiraFieldsBean(jiraFieldsBean);
				CRQToTaskThreadPoolExecuter crqToTaskThreadPoolExecuter = CRQToTaskThreadPoolExecuter
						.getInstance();
				crqToTaskThreadPoolExecuter
						.runTask(crqTaskListenerUpdateThreadPoolReader);

			}
		}
	}
}
	 */
